<?php

App::uses('AppController', 'Controller');

/**
 * subclaselaboratorio Controller
 *
 * @property Subclaseslaboratorio $sbcl
 */
class SubclasesresultadosController extends AppController {

    public $layout = 'hospital';
    public $uses = array('Subclasesresultado','Clasesresultado');
    /**
     * index method
     *
     * @return void
     */

    public function beforeFilter() {
        parent::beforeFilter();
        //$this->Auth->allow();
    }

    public function index() {
       $sub = $this->Subclasesresultado->find('all', array('recursive'=>1));
        $this->set(compact('sub'));
    }

    /**
     * view method
     *
     * @throws NotFoundException    
     * @param string $id
     * @return void
     */
    public function view($id = null) {
        if (!$this->Subclasesresultado->exists($id)) {
            throw new NotFoundException(__('Invalid subclaseslaboratorio'));
        }
        $options = array('conditions' => array('Subclasesresultado' . $this->Subclasesresultado->primaryKey => $id));
        $this->set('Subclasesresultado', $this->Subclasesresultado->find('first', $options));
    }

    /**s
     * add method
     *
     * @return void
     */
    public function add() {

        if ($this->request->is('post')) {
            //debug($this->request->data);exit;
            $this->Subclasesresultado->create();

            if ($this->Subclasesresultado->save($this->request->data)) {
                $this->Session->setFlash(__('The Subclasesresultado has been saved'));
                $this->redirect(array('action' => 'index'));
            } else {
                $this->Session->setFlash(__('The Subclasesresultado could not be saved. Please, try again.'));
            }
        } 
        else{

            $clasesresultado = $this->Clasesresultado->find('all',
                    array('fields'=>array('Clasesresultado.id','Clasesresultado.nombre'),
                        'recursive'=>-1
                        ));
             //debug($claseslaboratorio); exit;
            $this->set(compact('clasesresultado'));        
                    
        }


        //$parametros = $this->Parametro->find('list');
        //$this->set(compact('parametros'));
    }

    /**
     * edit method
     *
     * @throws NotFoundException
     * @param string $id
     * @return void
     */
    public function edit($id = null) {

        if (!$this->Subclasesresultado->exists($id)) {
            throw new NotFoundException(__('Invalid Subclasesresultado'));
        }
        if ($this->request->is('post') || $this->request->is('put')) {
            //debug($this->request->data());exit;
            $this->Subclasesresultado->id = $id;
            if ($this->Subclasesresultado->save($this->request->data)) {
                $this->Session->setFlash(__('The Subclasesresultado has been saved'));
                $this->redirect(array('action' => 'index'));
            } else {
                $this->Session->setFlash(__('The Subclasesresultado could not be saved. Please, try again.'));
            }
        } else {
            $options = array('conditions' => array('Subclasesresultado.' . $this->Subclasesresultado->primaryKey => $id));
            $this->request->data = $this->Subclasesresultado->find('first', $options);
        }
        $clasesresultado=$this->Clasesresultado->find('all',array('recursive'=>-1));
        //$parametros = $this->Parametro->find('list');
        $this->set(compact('clasesresultado'));
    }
 

    /**
     * delete method
     *
     * @throws NotFoundException
     * @throws MethodNotAllowedException
     * @param string $id
     * @return void
     */
    public function delete($id = null) {
        $this->Subclasesresultado->id = $id;
        if (!$this->Subclasesresultado->exists()) {
            throw new NotFoundException(__('Invalid Subclasesresultado'));
        }
        //$this->request->onlyAllow('post', 'delete');
        if ($this->Subclasesresultado->delete()) {
            $this->Session->setFlash(__('Subclasesresultado deleted'));
            $this->redirect(array('action' => 'index'));
        }
        $this->Session->setFlash(__('Subclasesresultado was not deleted'));
        $this->redirect(array('action' => 'index'));
    }
}
